package team.seekers.hula.teamwork.team.team.controller;


import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.teamwork.team.team.entity.dto.TeamAddPA;
import team.seekers.hula.teamwork.team.team.entity.dto.TeamQuery;
import team.seekers.hula.teamwork.team.team.entity.dto.TeamUpdatePA;
import team.seekers.hula.teamwork.team.team.entity.vo.TeamListVO;
import team.seekers.hula.teamwork.team.team.entity.vo.TeamManageInfoVO;
import team.seekers.hula.teamwork.team.team.service.TeamManageService;
import java.util.List;

/**
 * 团队管理 前端控制器
 * @author yiming
 */
@Controller
@ApiResponseBody
@RequestMapping("/manage/team")
public class TeamManageController {

    @Autowired
    private TeamManageService teamManageService;

    @GetMapping("/info")
    public TeamManageInfoVO info(@RequestParam String id) {
        return teamManageService.get(id);
    }



    @ApiOperation(value = "渲染所有创建的团队")
    @GetMapping("/list-me-create")
    public List<TeamListVO> listMeCreate() {
        return teamManageService.listMeCreate();
    }


    @ApiOperation(value = "新建团队")
    @PostMapping("/add")
    public void add( @RequestBody TeamAddPA teamAddPA) {
        teamManageService.add(teamAddPA);
    }



    @ApiOperation(value = "编辑团队")
    @PostMapping("/update")
    public void update( @RequestBody TeamUpdatePA teamUpdatePA) {
        teamManageService.update(teamUpdatePA);
    }


    @ApiOperation(value = "解散团队")
    @DeleteMapping("/delete")
    public void delete(@RequestParam String id) {
        teamManageService.delete(id);
    }



    @ApiOperation(value = "根据团队名分页查询")
    @PostMapping("/page-query")
    public PageResult<TeamListVO> pageQueryByTitle(@RequestBody() TeamQuery teamQuery) {
        return teamManageService.pageQuery(teamQuery);
    }



}

